<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/tool.js"></script>
</head>

<body>

</body>
<script>
    // 断言
    // (?=n)   前瞻断言
    // (?!n)   前瞻否定断言
    // (?<=n)  后瞻断言
    // (?<!n)  后瞻否定断言

    var str = "abABC";
    var reg = /b(?=a)/ig; //匹配其后紧邻a的b
    var result = match(str, reg);
    console.log(result);

    var str = "abABC";
    var reg = /b(?!a)/ig; //匹配其后不紧邻a的b
    var result = match(str, reg);
    console.log(result);

    var str = "abABC";
    var reg = /(?<=b)a/ig; // 匹配前面紧邻b的a
    var result = match(str, reg);
    console.log(result);

    var str = "abABC";
    var reg = /(?<!b)a/ig; // 匹配前面不紧邻b的a
    var result = match(str, reg);
    console.log(result);




</script>

</html>